package com.it.flowable.dto;

import lombok.Data;
import lombok.experimental.Accessors;
import org.flowable.bpmn.model.FormValue;

/**
 * 表单值选项数据传输对象
 */
@Data
@Accessors(chain = true)
public class FormValueDto {
    
    /** 选项ID */
    private String id;
    
    /** 选项名称 */
    private String name;
    
    /** 选项值 */
    private String value;
    
    /** 排序序号 */
    private Integer sortOrder;
    
    // ==================== 构造方法 ====================
    public FormValueDto() {
    }
    
    public FormValueDto(FormValue formValue) {
        if (formValue != null) {
            this.id = formValue.getId();
            this.name = formValue.getName();
        }
    }
    
    public FormValueDto(String id, String name) {
        this.id = id;
        this.name = name;
    }
    
    public FormValueDto(String id, String name, String value) {
        this.id = id;
        this.name = name;
        this.value = value;
    }
    
    /**
     * 转换为 FormValue
     */
    public FormValue toFormValue() {
        FormValue formValue = new FormValue();
        formValue.setId(this.id);
        formValue.setName(this.name);
        return formValue;
    }
}